#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e4+10;
const int inf = 0x3f3f3f3f;

#define in read()
typedef long long ll;

ll dis[MAXN];
int a[MAXN],D,b[MAXN],h[MAXN],cnt,q[MAXN],n,m,root,SIZ,MX,siz[MAXN],son[MAXN];
bool ANS[MAXN],vis[MAXN];

struct edge{int v,w,nxt;}e[MAXN<<1];

void link(int x,int y,int w){e[++cnt] = (edge){y,w,h[x]};h[x]=cnt;}

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

void getroot(int x,int p){
	siz[x] = 1,son[x] = 0;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		if(vis[y] || y == p) continue;
		getroot(y,x);
		siz[x] += siz[y];
		if(siz[y] > son[x]) son[x] = siz[y];
	}
	son[x] = max(son[x],SIZ - son[x]);
	if(son[x] < MX) root = x,MX = son[x];
}

bool cmp(int x,int y){return dis[x] < dis[y];}

void getdis(int x,int p,ll w,int fro){
	dis[x] = w;
	a[++D] = x;
	b[x] = fro;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		if(!vis[y] && y != p) getdis(y,x,w+e[i].w,fro);
	}
}

void cal(int x){
	D = 0;
	a[++D] = x;
	dis[x] = 0;
	b[x] = x;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;
		if(!vis[y]) getdis(y,x,e[i].w,y);
	}
	sort(a+1,a+D+1,cmp);
	for(int i = 1;i <= m;i++){
		if(ANS[i]) continue;
		int l = 1,r = D;
		while(l < r){
			if(dis[a[l]] + dis[a[r]] > q[i]) r--;
			else if(dis[a[l]] + dis[a[r]] < q[i]) l++;
			else if(b[a[l]] == b[a[r]]){
				if(dis[a[r]] == dis[a[r-1]]) r--;
				else l++;
			}else {ANS[i] = 1;break;}
		}
	}
}

void Divide(int x){
	vis[x] = 1;cal(x);
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v;if(vis[y]) continue;
		root = 0;MX = inf;SIZ = siz[y];
		getroot(y,0);
		Divide(root);
	}
}

int main (){
	n = in,m = in;
	for(int i = 1;i < n;i++){
		int x = in,y = in,w = in;
		link(x,y,w);link(y,x,w);
	}
	for(int i = 1;i <= m;i++) q[i] = in;
	SIZ = n; root = 0; MX = inf;
	getroot(1,0);
	Divide(root);
	for(int i = 1;i <= m;i++) puts(ANS[i]?"AYE":"NAY");
	return 0;
}
